Skip to content

[pull] main from tldraw:main#490

Merged
pull[bot] merged 4 commits intocode:mainfrom
tldraw:main
Apr 10, 2026
Merged

[pull] main from tldraw:main#490
pull[bot] merged 4 commits intocode:mainfrom
tldraw:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Apr 10, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

ds300 and others added 4 commits April 10, 2026 07:13
alternate take on #8487 

### Change type

- [ ] `bugfix`
- [ ] `improvement`
- [ ] `feature`
- [ ] `api`
- [x] `other`
I spoke with @fat from pierre and agreed to a 10% trial of production
traffic so we could get a sense of how much space we'd consume as well
as what kind of write throughput we'd expect to see.

For throughput I added a workers analytics event to track the number of
bytes written in incremental writes. Then we can sum all the events in
grafana and multiply by 10 to get a realistic view of write throughput.

For disk space consumption I'll be running some separate tests using
staging R2 snapshot data to 'migrate' existing rooms to pierre to get a
sense of what kind of compression factor it offers (i think it'll be
logarithmic and dependent on usage patterns), and then we can try to
apply that to the production R2 bucket to get a good sense of how much
space we'd be using.

### Change type

- [x] `other`
In order to prevent a context menu from briefly flashing when
right-clicking to dismiss an already-open context menu, this PR
intercepts the browser's `contextmenu` event before it can reach the
Radix Trigger.

Closes #8479
Closes #8251

**Root cause:** When a menu is open, `MenuClickCapture` overlays the
canvas. On right-click, `handlePointerDown` calls `clearOpenMenus()`,
which triggers a synchronous render that unmounts `MenuClickCapture`
itself. The browser's `contextmenu` event — which fires after
`pointerdown` — then passes through to the Radix `ContextMenu.Trigger`
unopposed, briefly opening a new context menu. Radix's
`DismissableLayer` immediately detects the pointer is outside and
dismisses it, producing a visible flash.

**Fix:** Before calling `clearOpenMenus()`, register a one-shot
capture-phase `contextmenu` listener on the document that swallows the
event with `stopImmediatePropagation()`. This prevents the event from
ever reaching Radix. The listener auto-removes via `{ once: true }`. A
React `onContextMenu` handler is also added to `MenuClickCapture` as a
belt-and-suspenders guard for cases where the component hasn't unmounted
yet.

### Change type

- [x] `bugfix`

### Test plan

1. Right-click on the canvas — context menu appears
2. Right-click elsewhere on the canvas — context menu dismisses cleanly,
no flash
3. Repeat rapidly — no flash on any consecutive right-click
4. Right-click on a shape — context menu shows shape actions
5. Open a dropdown/toolbar menu, then right-click on canvas — dropdown
dismisses, no flash
6. Left-click or press Escape to dismiss context menu — still works as
before
7. Long-press on touch device — context menu still works (fix only
targets button 2)

- [ ] Unit tests
- [ ] End to end tests

### Release notes

- Fix context menu briefly flashing when right-clicking to dismiss an
already-open context menu.

### Code changes

| Section    | LOC change |
| ---------- | ---------- |
| Core code  | +20 / -0   |

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ems (#8499)

When right-clicking to open a context menu and moving the mouse quickly,
the `pointerup` (button 2) from the right-click can land on a menu item
and trigger selection without the user intending to click it.

Closes #8480

**Root cause:** Radix's `MenuItem` calls `event.currentTarget.click()`
on `pointerup` when `isPointerDownRef` is false (i.e. the pointer wasn't
pressed down on that item). This is intentional for drag-to-select
behavior, but it doesn't check the pointer button — so a right-click
release (button 2) triggers the same path as a left-click release.

**Fix:** Add an `onPointerUp` handler to `_ContextMenu.Item` that calls
`preventDefault()` for non-left-click buttons. Radix's
`composeEventHandlers` runs the user handler first and skips its
internal handler when `defaultPrevented` is true, so the synthetic
`click()` never fires.

### Change type

- [x] `bugfix`

### Test plan

1. Right-click on empty canvas — context menu appears
2. Move mouse quickly across menu items — no item should activate
3. Right-click on a shape, move fast across items — no item should
activate
4. Left-click a menu item normally — should still work
5. Drag from outside the menu onto an item and release (left button) —
should still select

- [ ] Unit tests
- [ ] End to end tests

### Release notes

- Fix context menu items being accidentally selected when right-clicking
and quickly moving the mouse.

### Code changes

| Section    | LOC change |
| ---------- | ---------- |
| Core code  | +9 / -0    |

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pull pull Bot locked and limited conversation to collaborators Apr 10, 2026
@pull pull Bot added the ⤵️ pull label Apr 10, 2026
@pull pull Bot merged commit ce1f005 into code:main Apr 10, 2026
4 checks passed
@pull pull Bot had a problem deploying to deploy-staging April 10, 2026 09:13 Failure
@pull pull Bot had a problem deploying to deploy-production April 10, 2026 09:13 Failure
@pull pull Bot had a problem deploying to deploy-staging April 10, 2026 09:13 Error
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants